package com.jstyle.jclife.adapter;

import android.content.Context;

import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.jstyle.jclife.R;
import com.jstyle.jclife.model.Teamperformance;
import com.jstyle.jclife.utils.ScreenUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


public class TeamperdataAdapter extends RecyclerView.Adapter{
    private List<Teamperformance> mData;
    private Context context;
    public TeamperdataAdapter(Context mycontext) {
        this.context =mycontext;
    }
    public  void  SettingData(List<Teamperformance> mymData){
        this.mData =mymData;
        notifyDataSetChanged();
    }


    @Override
    public int getItemViewType(int position) {
        if (position == 0) {
            return 0;
        } else {
            return 1;
        }
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view;
        if(0==viewType){
            view=   LayoutInflater.from(context).inflate(R.layout.item_teamdata,  parent,false);
            return   new ExerciseRecor1(view);
        }else{
            view=   LayoutInflater.from(context).inflate(R.layout.item_teamdataer,  parent,false);
            return   new ExerciseRecor2(view);
        }
    }
    public class ExerciseRecor1 extends BaseViewHolder {//其他剩下的
        @BindView(R.id.title_name)
        TextView ti;
        @BindView(R.id.others)
        TextView t2;
        @BindView(R.id.otherer)
        TextView t3;
        @BindView(R.id.othersan)
        TextView t4;
        public ExerciseRecor1(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
    public class ExerciseRecor2 extends BaseViewHolder {//其他剩下的
        @BindView(R.id.title_name)
        TextView ti;
        @BindView(R.id.others)
        TextView t2;
        @BindView(R.id.otherer)
        TextView t3;
        @BindView(R.id.othersan)
        TextView t4;
        @BindView(R.id.item_lineer)
        View view;
        public ExerciseRecor2(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
    @Override
    public void onBindViewHolder( RecyclerView.ViewHolder holder, int position) {
      if(holder instanceof ExerciseRecor1){

          ExerciseRecor1 normalViewHolder=(ExerciseRecor1)holder;
          normalViewHolder. t2.setTextColor(Color.parseColor("#003D5C"));
          normalViewHolder.t3.setTextColor(Color.parseColor("#003D5C"));
          normalViewHolder.t4.setTextColor(Color.parseColor("#003D5C"));
          normalViewHolder.ti.setText("");
          if (mData.size()>=3){
              normalViewHolder.t2.setText(mData.get(0).getTeampnmae().replace("\\n", ""));
              normalViewHolder.t3.setText(mData.get(1).getTeampnmae().replace("\\n", ""));
              normalViewHolder. t4.setText(mData.get(2).getTeampnmae().replace("\\n", ""));
          }else if(mData.size()>=2){
              normalViewHolder.t2.setText(mData.get(0).getTeampnmae().replace("\\n", ""));
              normalViewHolder.t3.setText(mData.get(1).getTeampnmae().replace("\\n", ""));
          }else{
              normalViewHolder.t2.setText(mData.get(0).getTeampnmae().replace("\\n", ""));
          }
          if (mData.size()==2){
              normalViewHolder.t4.setVisibility(View.GONE);
          }else if(mData.size()==1){
              normalViewHolder.t3.setVisibility(View.GONE);
              normalViewHolder.t4.setVisibility(View.GONE);
          }
      }else{
          ExerciseRecor2 normalVi=(ExerciseRecor2)holder;
          if (mData.size()==2){
              normalVi.t4.setVisibility(View.GONE);
          }else if(mData.size()==1){
              normalVi.t3.setVisibility(View.GONE);
              normalVi.t4.setVisibility(View.GONE);
          }
          switch (position){
              case 1:
                  normalVi.ti.setText("达标数");
                  normalVi.t2.setText(mData.get(0).getTargetNumber()+"");
                  if(mData.size()>=2){ normalVi.t3.setText(mData.get(1).getTargetNumber()+""); }
                  if(mData.size()>=3){ normalVi.t4.setText(mData.get(2).getTargetNumber()+""); }
                  break;
              case 2:
                  normalVi.ti.setText("平均时长");
                  normalVi.t2.setText(mData.get(0).getAverageDuration());
                  if(mData.size()>=2){ normalVi.t3.setText(mData.get(1).getAverageDuration()); }
                  if(mData.size()>=3){ normalVi.t4.setText(mData.get(2).getAverageDuration());}
                  break;
              case 3:
                  normalVi.ti.setText("平均距离");
                  normalVi.t2.setText(mData.get(0).getMeanDistance());
                  if(mData.size()>=2){ normalVi.t3.setText(mData.get(1).getMeanDistance()); }
                  if(mData.size()>=3){ normalVi.t4.setText(mData.get(2).getMeanDistance());}
                  break;
              case 4:
                  normalVi.ti.setText("平均步频");
                  normalVi.t2.setText(mData.get(0).getAverageStepFrequency());
                  if(mData.size()>=2){ normalVi.t3.setText(mData.get(1).getAverageStepFrequency()); }
                  if(mData.size()>=3){ normalVi.t4.setText(mData.get(2).getAverageStepFrequency());}
                  break;
              case 5:
                  normalVi.ti.setText("平均步数");
                  normalVi.t2.setText(mData.get(0).getAverageStepNumber());
                  if(mData.size()>=2){ normalVi.t3.setText(mData.get(1).getAverageStepNumber()); }
                  if(mData.size()>=3){ normalVi.t4.setText(mData.get(2).getAverageStepNumber());}
                  break;
              case 6:
                  normalVi.ti.setText("最快配速");
                  normalVi.t2.setText(mData.get(0).getFastestSpeedDistribution());
                  if(mData.size()>=2){ normalVi.t3.setText(mData.get(1).getFastestSpeedDistribution()); }
                  if(mData.size()>=3){ normalVi.t4.setText(mData.get(2).getFastestSpeedDistribution());}
                  break;
              case 7:
                  normalVi.ti.setText("平均配速");
                  normalVi.t2.setText(mData.get(0).getAverageSpeedDistribution());
                  if(mData.size()>=2){ normalVi.t3.setText(mData.get(1).getAverageSpeedDistribution()); }
                  if(mData.size()>=3){ normalVi.t4.setText(mData.get(2).getAverageSpeedDistribution());}
                  break;

          }


      }
        Log.e("asdasdada",position+"");


    }

    private void SettingtextView(TextView ti,TextView t2,TextView t3,TextView t4){
        ti.setTextColor(Color.parseColor("#656565"));
        t2.setTextColor(Color.parseColor("#282828"));
        t3.setTextColor(Color.parseColor("#282828"));
        t4.setTextColor(Color.parseColor("#282828"));
        ti.setTextSize(16f);
        t2.setTextSize(16f);
        t3.setTextSize(16f);
        t4.setTextSize(16f);
    }


    @Override
    public int getItemCount() {
        return 8;
    }






 /*   private void binddata(BaseViewHolder holder, int position) {
        dataViewHolder viewHolder = (dataViewHolder) holder;
        switch (mData.size()){
            case 1:
                viewHolder.otherser.setVisibility(View.GONE);
                viewHolder.otherssan.setVisibility(View.GONE);
                break;
            case 2:
                viewHolder.otherssan.setVisibility(View.GONE);
                break;
        }
        switch (position){
            case 0:
                viewHolder.title_name.setText("达标数");
                viewHolder.others.setText(mData.get(0).getTargetNumber()+"");
                viewHolder.otherser.setText(mData.get(1).getTargetNumber()+"");
                viewHolder.otherssan.setText(mData.get(2).getTargetNumber()+"");
            break;
            case 1:
                viewHolder.title_name.setText("平均时长");
                viewHolder.others.setText(mData.get(0).getAverageDuration());
                viewHolder.otherser.setText(mData.get(1).getAverageDuration());
                viewHolder.otherssan.setText(mData.get(2).getAverageDuration());
                break;
            case 2:
                viewHolder.title_name.setText("平均距离");
                viewHolder.others.setText(mData.get(0).getMeanDistance());
                viewHolder.otherser.setText(mData.get(1).getMeanDistance());
                viewHolder.otherssan.setText(mData.get(2).getMeanDistance());
                break;
            case 3:
                viewHolder.title_name.setText("平均步频");
                viewHolder.others.setText(mData.get(0).getAverageStepFrequency());
                viewHolder.otherser.setText(mData.get(1).getAverageStepFrequency());
                viewHolder.otherssan.setText(mData.get(2).getAverageStepFrequency());
                break;
            case 4:
                viewHolder.title_name.setText("平均步数");
                viewHolder.others.setText(mData.get(0).getAverageStepNumber());
                viewHolder.otherser.setText(mData.get(1).getAverageStepNumber());
                viewHolder.otherssan.setText(mData.get(2).getAverageStepNumber());
                break;
            case 5:
                viewHolder.title_name.setText("最快配速");
                viewHolder.others.setText(mData.get(0).getFastestSpeedDistribution());
                viewHolder.otherser.setText(mData.get(1).getFastestSpeedDistribution());
                viewHolder.otherssan.setText(mData.get(2).getFastestSpeedDistribution());
                break;
            case 6:
                viewHolder.title_name.setText("平均配速");
                viewHolder.others.setText(mData.get(0).getAverageSpeedDistribution());
                viewHolder.otherser.setText(mData.get(1).getAverageSpeedDistribution());
                viewHolder.otherssan.setText(mData.get(2).getAverageSpeedDistribution());
                break;
        }



    }
*/









}
